package com.wyu.service;



import com.wyu.dao.UserMapper;
import com.wyu.pojo.User;

public class UserServiceImpl implements UserService {
    //调用dao层的操作，设置一个set接口，方便Spring管理


    private UserMapper userMapper ;

    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }




    @Override
    public void registUser(User user) {
        userMapper.saveUser(user);
    }

    @Override
    public User login(User user) {
        return userMapper.queryUserByUsernameAndPassword(user.getUsername(), user.getPassword());
    }

    @Override
    public boolean existsUsername(String username) {

        if (userMapper.queryUserByUsername(username) == null) {
           // 等于null,说明没查到，没查到表示可用
           return false;
        }

        return true;

    }
}
